package com.example.clsj.organization;

import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.List;

@Slf4j
public class Manager extends Employee {

    private List<Employee> employees = new ArrayList<>();

    public Manager(String name, int id) {
        super(name, id);
    }

    @Override
    public void add(Employee employee) {
        employees.add(employee);
    }

    @Override
    public void remove(Employee employee) {
        employees.remove(employee);
    }

    @Override
    public void display(int depth) {
        log.info(StrUtil.repeat(' ', depth * 2) + "Manager: " + getName() + ", ID: " + getId());
        for (Employee employee : employees) {
            employee.display(depth + 1);
        }
    }

    @Override
    public int countEmployees() {
        int count = 1; // Count the manager itself
        for (Employee employee : employees) {
            count += employee.countEmployees();
        }
        return count;
    }

    @Override
    public double calculateTotalSalary() {
        double totalSalary = 10000; // Assume a fixed salary for managers
        for (Employee employee : employees) {
            totalSalary += employee.calculateTotalSalary();
        }
        return totalSalary;
    }
}
